<template>
  <div>
    <Spin :spinning="loading" tip="Loading...">
      <!-- table -->
      <FormPanel ref="formPanel" :list="formList" :cols="2" :formType="'add'" labelWidth="100" :isSubmitBtn="false" @formChange="formChangeHandle" />
      <div style="padding-top: 0.5rem;"></div>
      <div
        :style="{
          position: 'absolute',
          left: 0,
          right: 0,
          zIndex: 9,
          borderTop: '1px solid #e9e9e9',
          padding: '10px 20px',
          background: '#fff',
          textAlign: 'right'
        }"
      >
        <multiuse-button type="primary" :click="saveDialog.bind()">审核通过</multiuse-button>
        <multiuse-button @click="closeDialog">审核驳回</multiuse-button>
      </div>
    </Spin>
  </div>
</template>

<script>
import { updateState } from '@/api/serviceass/batteryAlarm/batteryAlarmManage'
  export default {
    name: "index",
    components: {
    },
    props: {
      formData: {
        type: Object,
        default: () => ({})
      }
  },
    data() {
      return {
        flterValue: {}, //参数
        fetchParams: {}, //ipa 接口
        formList: this.createFormList(),
        saveData: null,
        val: null,
        createdBy:'',
        loading: false,
        selectCheckFlag: false,
        rowData: {}
      }
    },
    methods: {
      async saveDialog() {
        // this.$refs.formPanel.SUBMIT_FORM();
          this.rowData.checkNote = this.formList.find((x) => x.fieldName === 'checkNote').initialValue;
          this.rowData.bwId = this.formData.bwId;
          this.rowData.state = 55661005;
          let res = await updateState(this.rowData);
          if (res.resultCode === 200) {
            this.$emit('close');
            return this.$notify.success({title: '提示信息', message: '审核成功'});
          } else {
            this.loading = false;
          }
      },
      //搜索获取数据
      changeHandle(val) {
        this.fetchParams = val;
      },
      //取消操作
      async closeDialog() {
          this.rowData.checkNote = this.formList.find((x) => x.fieldName === 'checkNote').initialValue;
          this.rowData.bwId = this.formData.bwId;
          this.rowData.state = 55661004;
          let res = await updateState(this.rowData);
          if (res.resultCode === 200) {
            this.$emit('close');
            return this.$notify.success({title: '提示信息', message: '审核驳回'});
          } else {
            this.loading = false;
          }
      },
      createFormList() {
        return [
          {
            type: 'TEXT_AREA',
            label: '审核意见',
            fieldName: 'checkNote',
            initialValue: '',
            placeholder: '',
            selfCols: 2,
            
          },
        ];
      },
      formChangeHandle(val) {
        this.saveData = _.cloneDeep(val);
      },
    }
  }
</script>

<style scoped>

</style>
